[DeadCode][Php80] Handle crash on mix ClassPropertyAssignToConstructorPromotionRector+RemoveParentDelegatingConstructorRector#7794
Closed
samsonasik wants to merge 4 commits intomainfrom
Closed
[DeadCode][Php80] Handle crash on mix ClassPropertyAssignToConstructorPromotionRector+RemoveParentDelegatingConstructorRector#7794samsonasik wants to merge 4 commits intomainfrom
samsonasik wants to merge 4 commits intomainfrom
Conversation
…rPromotionRector+RemoveParentDelegatingConstructorRector
samsonasik
commented
Jan 2, 2026
src/Rector/AbstractRector.php
Outdated
Comment on lines
+140
to
+146
| // this reindex is needed as when multiple rules apply | ||
| // the existing node position can already be removed/moved by different rule from "parent" node | ||
| // | ||
| // that modify/remove deep node, for example: | ||
| // - first rule: - Class_ → ClassMethod → remove index 0 | ||
| // - second rule: - ClassMethod → here fetch the index 0 no longer exists | ||
| NodeAttributeReIndexer::reIndexNodeAttributes($node); |
Member
Author
There was a problem hiding this comment.
@TomasVotruba this is the fix, the reindex early before refactor() is needed, as the node position can already be removed by other rule that use parent node as node type to check.
I added comment above for future reference.
Member
Author
|
Fixed 🎉 /cc @raneomik |
Member
Author
|
@TomasVotruba ready 👍 |
Member
Author
|
@TomasVotruba I created alternative PR for it at: which reindex is only on after refactor when refactored node returned, but with traverser to avoid issues when multiples rules apply, and higher node remove deep node so reindex is needed in deep. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes rectorphp/rector#9577
Ref https://getrector.com/demo/f693662b-ce0d-45cf-93d6-cf7d9674a06f